<?php

/**
 *      FROM:www.1314study.com
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: admincp.inc.php zhugeyun $
 */

if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
	exit('Access Denied http://51weixuecom.gotoip4.com/ 1356602442');
}
require_once DISCUZ_ROOT.'./source/discuz_version.php';
$disucz_version = DISCUZ_VERSION;
if(in_array($disucz_version,array('X1.5','X2'))){
	$data_dir = 'cache';
}else{
	$data_dir = 'sysdata';
}

$Plang = $scriptlang['study_nge'];
//print_r(get_defined_vars()); 

//print_r($Plang);
loadcache(plugin);
$study_nge = $_G['cache']['plugin']['study_nge'];

if(submitcheck('nge_submit',1)){
$update_item = $_GET[update_item] ? $_GET[update_item] : array();
if(empty($update_item)){
	if($study_nge[pic_select] != 1){
	$study_nge['pic_way'] = $study_nge['pic_way'] ? $study_nge['pic_way'] : 'flash';
	$update_item[] = "pic_".$study_nge['pic_way'];
	}
	
	$middle_order = $study_nge['middle_order'] ? $study_nge['middle_order'] :'2,3,4,5,6';
	$middle_order_array = explode(',',$middle_order);
	if(in_array('2',$middle_order_array)){
	$update_item[] = "newpost";
	}
	if(in_array('3',$middle_order_array)){
	$update_item[] = "newreply";
	}
	if(in_array('4',$middle_order_array)){
	$update_item[] = "recpost";
	}
	if(in_array('5',$middle_order_array)){
	$update_item[] = "goodreply";
	}
	if(in_array('6',$middle_order_array)){
	$update_item[] ="hotpost";
	}
	
	
	$right_order = $study_nge['right_order'] ? $study_nge['right_order'] :'';
	if(!empty($right_order)){	
		$right_order_array = explode(',',$right_order);
		if(in_array('7',$right_order_array)){
			$update_item[] = "newmember";
		}
		if(in_array('7',$right_order_array)){
			$update_item[] = "posts";
		}
		if(in_array('7',$right_order_array)){
			$update_item[] = "online";
		}
	}
}

foreach($update_item as $item){
	$file = DISCUZ_ROOT.'./data/'.$data_dir.'/cache_study_nge_'.$item.'.php';
	//echo $file;
	clearstatcache();
	if(file_exists($file)){
		$result = @unlink ($file);
		if ($result == false) {
		   exit('Can not update to cache files, please check directory ./data/ and ./data/'.$data_dir.'/ .');
		}
	}
}
cpmsg($Plang[study_nge_admincp_1].count($update_item).$Plang[study_nge_admincp_2],"action=plugins&operation=config&do=$pluginid&identifier=study_nge&pmod=admincp",'succeed');

}else{

showtips($Plang[study_nge_admincp_showtips]);

showformheader("plugins&operation=config&do=$pluginid&identifier=study_nge&pmod=admincp&submit=yes",'submit');

$checkbox_items = '';
if($study_nge[pic_select] != '1'){
$study_nge['pic_way'] = $study_nge['pic_way'] ? $study_nge['pic_way'] : 'flash';
$checkbox_items .= '<input type="checkbox" class="checkbox" name="update_item[]" value="pic_'.$study_nge['pic_way'].'" '.($_G['gp_badpwd'] ? ' checked="checked"' : '').'/>'.$Plang[study_pic_title];
}

$middle_order = $study_nge['middle_order'] ? $study_nge['middle_order'] :'2,3,4,5,6';
$middle_order_array = explode(',',$middle_order);
if(in_array('2',$middle_order_array)){
$checkbox_items .= '<input type="checkbox" class="checkbox" name="update_item[]" value="newpost" '.($_G['gp_diff_area'] ? ' checked="checked"' : '').'/>'.$Plang[study_newpost_title];
}
if(in_array('3',$middle_order_array)){
$checkbox_items .= '<input type="checkbox" class="checkbox" name="update_item[]" value="newreply" '.($_G['gp_diff_area'] ? ' checked="checked"' : '').'/>'.$Plang[study_newreply_title];
}
if(in_array('4',$middle_order_array)){
$checkbox_items .= '<input type="checkbox" class="checkbox" name="update_item[]" value="recpost" '.($_G['gp_diff_area'] ? ' checked="checked"' : '').'/>'.$Plang[study_recpost_title];
}
if(in_array('5',$middle_order_array)){
$checkbox_items .= '<input type="checkbox" class="checkbox" name="update_item[]" value="goodreply" '.($_G['gp_diff_area'] ? ' checked="checked"' : '').'/>'.$Plang[study_goodreply_title];
}
if(in_array('6',$middle_order_array)){
$checkbox_items .= '<input type="checkbox" class="checkbox" name="update_item[]" value="hotpost" '.($_G['gp_diff_area'] ? ' checked="checked"' : '').'/>'.$Plang[study_hotpost_title];
}


$right_order = $study_nge['right_order'] ? $study_nge['right_order'] :'';
if(!empty($right_order)){	
	$right_order_array = explode(',',$right_order);
	if(in_array('7',$right_order_array)){
		$checkbox_items .= '<input type="checkbox" class="checkbox" name="update_item[]" value="newmember" '.($_G['gp_diff_area'] ? ' checked="checked"' : '').'/>'.$Plang[study_newmember_title];
	}
	if(in_array('7',$right_order_array)){
		$checkbox_items .= '<input type="checkbox" class="checkbox" name="update_item[]" value="posts" '.($_G['gp_diff_area'] ? ' checked="checked"' : '').'/>'.$Plang[study_posts_title];
	}
	if(in_array('7',$right_order_array)){
		$checkbox_items .= '<input type="checkbox" class="checkbox" name="update_item[]" value="online" '.($_G['gp_diff_area'] ? ' checked="checked"' : '').'/>'.$Plang[study_online_title];
	}
}
showtableheader($Plang[study_nge_admincp_3]);
	showtablerow('', array('class="td23"'), 
		array($Plang[study_nge_admincp_4],$checkbox_items)
	);
showsubmit('nge_submit', $Plang[study_nge_admincp_5]);
showtablefooter();
}
?>